//处理路径拼接
// handlerPathJoin(["/a", "/b", "c"]);
export const handlerPathJoin = (paths) => {
  let str = "";
  paths.forEach((item) => {
    const url = item.trim();
    if (url) {
      if (url.startsWith("/")) {
        str += url;
      } else {
        str += `/${url}`;
      }
    }
  });
  return str;
};
// 处理api返回图片路径
export const handlerPicPath = (pic, key = "pic") => {
  if (typeof pic === "string") {
    const p = pic.replace(/\\/g, "/").replace("public", "");
    return import.meta.env.import.meta.env.VITE_HOST_URL + p;
  } else if (Array.isArray(pic)) {
    return pic.map((item) => {
      const res = { ...item };
      const p = res[key].replace(/\\/g, "/").replace("public", "");
      res[key] = import.meta.env.VITE_HOST_URL + p;
      return res;
    });
  }
  return pic;
};
